import axios from 'axios'
//获取后台后台接口的IP和端口号
import serverEnv from '../../../config/serverEnv'
axios.defaults.baseURL = serverEnv;
//解决axios post不能传递参数
import qs from 'qs'

const index = {
	state: {
		themes: [],
		checked: ""
	},
	getters: {
		getThemeChecked: (state) => {
			return state.checked;
		}
	},
	mutations: {
		getThemes: (state, payload) => {
			state.themes = payload.themes;
			state.checked = payload.checked;
		},
		changetheme: (state, payload) => {
			var obj = qs.stringify({
				themes: payload
			});
			axios.post('/themes/changeThemes', obj).then((res) => {
				state.checked = res.data.data.checked;
			})
		}
	},
	actions: {
		getThemesAct: (context, payload) => {
			context.commit('getThemes', payload);
		},
		changethemeAct: (context, payload) => {
			context.commit('changetheme', payload);
		}
	}
};
export default index;